import Vue from 'vue'
import VueRouter from 'vue-router'
import cover from "@/views/Cover";
import Main from "@/views/Main";
import Error from "@/views/Error";
import history from "@/views/history"
import login from "@/views/login";
import littleStation from "@/views/littleStation";
import Search from "@/views/Search";


Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
    // 主页路由配置
    {
        path: '/cover',
        component: cover
    },
    {
        path: '/MainPage',
        component: Main
    },
    {
        path: '/history',
        component: history
    },
    {
        path: '/login',
        component: login
    },
    {
        path: '/littleStation',
        component: littleStation
    },
    {
      path: '/search',
      component: Search
    },
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '*',       // 匹配不到路由,跳转404页面
        redirect: '/404'
    },
    {
        path: '/404',
        component:Error
    }
]

const router = new VueRouter({
    mode: "history",
    routes
})

export default router
